#include "Scene_PCH.h"
#include "SkydomeMgr.h"

/*--------------------------------------------------------------------------*/

SkydomeMgr::SkydomeMgr() :
	m_vao(NULL),
	m_radius(4000.0f * 1.025f)
{

}

/*--------------------------------------------------------------------------*/

SkydomeMgr::~SkydomeMgr()
{

}

/*--------------------------------------------------------------------------*/
const RMaterial* matta = NULL;
void SkydomeMgr::RenderSky( Camera* center )
{
	if (m_vao == NULL)
	{
		m_vao = g_Renderer->GetRendererStorageMgr()->GetVertexArray("sphere_0");
	}

	if (matta == NULL)
	{
		matta = g_Renderer->GetRendererStorageMgr()->GetMaterial("skydome_default");
	}
	
	g_Renderer->SetModelMatrix( glm::translate(center->GetWorldPosition()) * glm::scale(m_radius, m_radius, m_radius) );
	g_Renderer->BindMaterial(matta);
	g_Renderer->Draw(m_vao, ETopology::Triangles, m_vao->GetNumIndices(), 0, NULL);
}

/*--------------------------------------------------------------------------*/

void SkydomeMgr::SetSkydomeRadius( float radius )
{
	m_radius = radius;
}

/*--------------------------------------------------------------------------*/

float SkydomeMgr::GetSkydomeRadius() const
{
	return m_radius;
}

/*--------------------------------------------------------------------------*/
